<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2022/10/28
  Time: 22:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>我要买车</title>
    <link rel="shortcut icon" type="image/x-icon" href="images/nangua.jpg" media="screen" />
    <link type="text/css" href="css/buy.css" rel="stylesheet" />
    <link type="text/css" href="css/common.css" rel="stylesheet" />
    <link type="text/css" href="css/reset.css" rel="stylesheet" />


    <script type="text/javascript" src="js/index_type_more.js"></script>
    <script type="text/javascript" src="js/index_main_pic.js"></script>

</head>
<body>
<div class="index">

<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script><!--必须得放在第一的位置-->


    <script type="text/javascript">
        $(document).ready(function(){
            show(1,12);
            getCarBrand();
        });

        function getCarBrand() {
            $.ajax({
                url:"getCarBrand.do",
                type:"GET",
                dataType:"json",
                success:function (list) {
                    var str1='<dt>品牌：</dt>'+
                            '<dd class="select-all selected"><a href="javascript:void(0)">不限</a></dd>';
                    var str='';
                    if(list.length!=null){
                        for (var i = 0; i<list.length; i++) {
                            str=str+'<dd><a href="javascript:getCarDept(\''+list[i].car_brand+'\')">'+list[i].car_brand+'</a></dd>'
                        }
                    }
                    $("#select2").html(str1+str);



                }

            });
        };
        </script>
    <script>
        function show(page,size){
           var searchbrand=$("#searchkeys").val();
           if(searchbrand!=null&&searchbrand!=''){
               var car_brand =searchbrand;
           }else{
               var car_brand = $("#selectB").find('a').html();
           }

            //获取选中的标签
            var car_adress = $("#selectA").find('a').html();
            var car_dept = $("#selectC").find('a').html();
            var car_price=$("#selectE").find('a').html();
            var car_regist=$("#selectF").find('a').html();
            var car_mile=$("#selectH").find('a').html();
            var car_dc=$("#selectJ").find('a').html();
            var car_at=$("#selectK").find('a').html();
            var car_color=$("#selectL").find('a').html();
            var car_capacity=$("#selectM").find('a').html();
           // alert(page+","+size+","+car_adress+","+car_brand+","+car_dept+","+","+car_price+","+car_regist+","+car_mile+","+car_dc+","
          //  +car_at+","+car_color+","+car_capacity);
           $.ajax({
               url:"selectCarByMuplCondition.do",
               type:"GET",
               dataType:"json",
               data:{
                   car_adress:car_adress,car_brand:car_brand,car_dept:car_dept,car_price:car_price,car_regist:car_regist,
                   car_mile:car_mile,car_dc:car_dc,car_at:car_at,car_color:car_color,car_capacity:car_capacity,page:page,size:size},
               success:function (msg) {
                   if(msg.flag==1){
                       var datalist=msg.data.olist;
                       var html='';
                       for (var i = 0; i<datalist.length; i++) {
                           var html='';
                           for(var i=0;i<datalist.length;i++){
                               html+='<div class="buy_content_con_margin_l">';
                               html+='<div class="buy_content_con_c'+i+' buy_content_con_c width_h_292_276 over_hidden fl" onclick="">';
                               html+='<div class="buy_content_con_cc width_h_292_276">';
                               html+='<div class="buy_content_con_pic width_h_292_186">';
                               html+='<a href="queryCarByid.do?car_id='+datalist[i].car_id+'"><img src="'+'${applicationScope.basePath}'+'upload/'+datalist[i].pic_main+'" width="292" height="186"/></a>';
                               html+='</div>';
                               html+='<div class="buy_content_con_txt width_h_292_90">';
                               html+='<p class="p1">';
                               html+='<a title="'+datalist[i].car_name+'" href="queryCarByid.do?car_id='+datalist[i].car_id+'">'+datalist[i].car_name+'</a>';
                               html+='</p>';
                               html+='<p class="p2">';
                               html+='<span class="">'+datalist[i].car_regist+'上牌</span><em class="shuxian">|</em>行驶'+ datalist[i].car_mile+'万公里';
                               html+='</p>';
                               html+='<p class="p3">';
                               html+='<span><i class="fc-org priType">'+ datalist[i].car_price+'万</i></span><s>'+datalist[i].car_newprice+'万</s>';
                               html+='</p>';
                               html+='</div>';
                               html+='</div>';
                               html+='</div>';
                               html+='</div>';
                           }
                           $("#carlist").html(html)
                       }
                       var str = '';
                       str='<a href="javaScript:show(1,12)" style="padding: 4px 10px;background: #fff;font-size: 14px;color: #0B6FB0;margin: 0 3px;text-decoration: none;">首页</a>&nbsp;'+
                           '<a href="javaScript:show('+(msg.data.page-1)+',12)" style="padding: 4px 10px;background: #fff;font-size: 14px;color: #0B6FB0;margin: 0 3px;text-decoration: none;">上一页</a>&nbsp;'+
                           '<a href="javaScript:show('+(msg.data.page+1)+',12)" style="padding: 4px 10px;background: #fff;font-size: 14px;color: #0B6FB0;margin: 0 3px;text-decoration: none;">下一页</a>&nbsp;'+
                           '<a href="javaScript:show('+msg.data.maxPage+',12)" style="padding: 4px 10px;background: #fff;font-size: 14px;color: #0B6FB0;margin: 0 3px;text-decoration: none;">尾页</a>' ;

                       $("#mycarlist").html(html);
                       $("#pageandsize").html(str);//分页
                       $("#carnum").html(msg.data.allCount);
                   }else if(msg.flag==0){
                       alert("未找到符合你条件的车辆");
                      location.href="buycar.jsp";
                   }
               }

           });
        }
    </script>

    <script>
        function adddept(dept) {
            var d=dept;
            //判断是否有id=selectB的值，如果没有则赋值，如果有则替换

            var str= $("#selectC");


            if(str.length==0){
                //获取当前选择的车牌，显示再
                $("#selectB").after('<dd class="selected" id="selectC"><a >'+d+'</a></dd>');

                show(1,12);
            }else{
                $("#selectC a").html(d);
                show(1,12);
            }
        }

    </script>

    <script>
        function getCarDept(car_brand) {
            //判断是否有id=selectB的值，如果没有则赋值，如果有则替换
           var str= $("#selectB");
           if(str.length==0){
               //获取当前选择的车牌，显示再
               $("#myno").after('<dd class="selected" id="selectB"><a >'+car_brand+'</a></dd>');
               //去掉
               $("#myno").remove();
           }else{
               $("#selectB a").html(car_brand);
           }


            $.ajax({
                url:"getCarDeptByBrand.do",
                type:"GET",
                data:{car_brand:car_brand},
                dataType:"json",
                success:function (list) {
                    var str='';
                    str=str+'<dt>车系：</dt><dd class="select-all selected"><a href="javascript:void(0)">不限</a></dd>';
                    if(list.length>0){
                        for (var i = 0; i<list.length; i++) {
                        str=str+'<dd><a href="javascript:adddept(\''+list[i].car_dept+'\')">'+list[i].car_dept+'</a></dd>'
                        }
                    }
                    $("#select3").html(str);


                }

            });

           show(1,12);
        }
    </script>


    <!--头部导航-->
    <jsp:include page="head.jsp"></jsp:include>
    <!--头部导航结束-->

    <div class="hr_5"></div>
    <div class="buy_content width_1200_center">
        <div class="buy_content_cate background5 clearfix">
            <ul class="select">
                <li class="select-list" onclick="show(1,12)">
                    <dl id="select1">
                        <dt>地区：</dt>
                        <dd class="select-all selected"><a href="javascript:void(0)">不限</a></dd>
                        <dd><a href="javascript:void(0)">厦门市</a></dd>
                        <dd><a href="javascript:void(0)">北京市</a></dd>
                        <dd><a href="javascript:void(0)">上海市</a></dd>
                        <dd><a href="javascript:void(0)">广州市</a></dd>
                        <dd><a href="javascript:void(0)">深圳市</a></dd>
                        <dd><a href="javascript:void(0)">漳州市</a></dd>
                        <dd><a href="javascript:void(0)">杭州市</a></dd>
                        <dd><a href="javascript:void(0)">宁波市</a></dd>
                        <dd><a href="javascript:void(0)">桂林市</a></dd>
                        <dd><a href="javascript:void(0)">高雄市</a></dd>
                        <dd><a href="javascript:void(0)">南京市</a></dd>
                        <dd><a href="javascript:void(0)">青岛市</a></dd>
                        <dd><a href="javascript:void(0)">莆田市</a></dd>
                        <dd><a href="javascript:void(0)">宁德市</a></dd>
                    </dl>
                </li>
                <li class="select-list">
                    <dl id="select2">

                    </dl>
                </li>
                <li class="select-list" >
                    <dl id="select3">

                    </dl>
                </li>

                <li class="select-list" onclick="show(1,12)">
                    <dl id="select5">
                        <dt>价格：</dt>
                        <dd class="select-all selected"><a href="javascript:void(0)">不限</a></dd>
                        <dd><a href="javascript:void(0)">3万内</a></dd>
                        <dd><a href="javascript:void(0)">3-5万</a></dd>
                        <dd><a href="javascript:void(0)">5-8万</a></dd>
                        <dd><a href="javascript:void(0)">8-10万</a></dd>
                        <dd><a href="javascript:void(0)">10-15万</a></dd>
                        <dd><a href="javascript:void(0)">15-20万</a></dd>
                        <dd><a href="javascript:void(0)">20-30万</a></dd>
                        <dd><a href="javascript:void(0)">30-50万</a></dd>
                        <dd><a href="javascript:void(0)">50万以上</a></dd>
                    </dl>
                </li>
                <li class="select-list" >
                    <dl id="select6" onclick="show(1,12)">
                        <dt>车龄：</dt>
                        <dd class="select-all selected"><a href="javascript:void(0)">不限</a></dd>
                        <dd><a href="javascript:void(0)">1年内</a></dd>
                        <dd><a href="javascript:void(0)">2年内</a></dd>
                        <dd><a href="javascript:void(0)">3年内</a></dd>
                        <dd><a href="javascript:void(0)">3-5年</a></dd>
                        <dd><a href="javascript:void(0)">5-8年</a></dd>
                        <dd><a href="javascript:void(0)">8年以上</a></dd>
                    </dl>
                </li>
                <li class="select-list" onclick="show(1,12)">
                    <dl id="select7">
                        <dt>里程：</dt>
                        <dd class="select-all selected"><a href="javascript:void(0)">不限</a></dd>
                        <dd><a href="javascript:void(0)">1万公里内</a></dd>
                        <dd><a href="javascript:void(0)">3万公里内</a></dd>
                        <dd><a href="javascript:void(0)">5万公里内</a></dd>
                        <dd><a href="javascript:void(0)">5万公里以上</a></dd>
                    </dl>
                </li>

                <li class="select-result">
                    <dl class="select-result">
                        <dt>已选：</dt>
                        <dd class="select-no" id="myno" >暂时没有选择条件</dd>



                        <!--
                        <dd id="selectA"><a href="javascript:void(0)">柳州</a></dd>
                        <dd id="selectB"><a href="javascript:void(0)">奥迪</a></dd>
                        -->
                        <dd class="select-noo"></dd>

                    </dl>
                </li>
                <li class="select-list select-list8" onclick="show(1,12)">
                    <dl id="select8" class="select8">
                        <dt>其他：</dt>
                        <dd><span class="select8_pai"><span>排量</span><i></i></span></dd>
                        <dd><span class="select8_bian"><span>变速箱</span><i></i></span></dd>
                        <dd><span class="select8_color"><span>颜色</span><i></i></span></dd>
                        <dd><span class="select8_country"><span>国别</span><i></i></span></dd>
                        <div class="select8_pai1 width_h_280_82 position_ab background5 display_n"><p class="p1"><a href="javascript:void(0)">1.0升以下</a><a href="javascript:void(0)">1.1-1.5升</a><a href="javascript:void(0)">1.6-2.0升</a><a href="javascript:void(0)">2.1-3.0升</a><a href="javascript:void(0)">3.1升以上</a></p></div><div class="select8_bian1 width_h_280_82 position_ab background5 display_n"><p class="p1"><a href="javascript:void(0)">手动</a><a href="javascript:void(0)">自动</a></div><div class="select8_color1 width_h_280_82 position_ab background5 display_n"><p class="p1"><a href="javascript:void(0)">黑色</a><a href="javascript:void(0)">白色</a><a href="javascript:void(0)">红色</a><a href="javascript:void(0)">蓝色</a><a href="javascript:void(0)">香槟色</a><a href="javascript:void(0)">绿色</a><a href="javascript:void(0)">黄色</a><a href="javascript:void(0)">橙色</a><a href="javascript:void(0)">紫色</a><a href="javascript:void(0)">银灰色</a><a href="javascript:void(0)">深灰色</a><a href="javascript:void(0)">咖啡色</a><a href="javascript:void(0)">多彩色</a><a href="javascript:void(0)">其他</a></p></div><div class="select8_country1 width_h_280_82 position_ab background5 display_n"><p class="p1"><a href="javascript:void(0)">中国</a><a href="javascript:void(0)">德国</a><a href="javascript:void(0)">法国</a><a href="javascript:void(0)">意大利</a><a href="javascript:void(0)">捷克</a><a href="javascript:void(0)">美国</a><a href="javascript:void(0)">西拔牙</a><a href="javascript:void(0)">澳大利亚</a><a href="javascript:void(0)">韩国</a><a href="javascript:void(0)">英国</a><a href="javascript:void(0)">瑞典</a><a href="javascript:void(0)">日本</a></p></div>
                    </dl>
                </li>
            </ul>
        </div>
        <div class="hr_10"></div>
    </div>

    <div class="buy_content_li width_1200_center">
            <div class="buy_content_li_top clearfix">
                <div class="buy_content_li_top_default fl"><a href="#">默认排序</a></div>
                <div class="buy_content_li_top_price fl"><a href="#">价格</a></div>
                <div class="buy_content_li_top_mile fl"><a href="#">里程</a></div>
                <div class="buy_content_li_top_age fl"><a href="#">车龄</a></div>
                <div class="buy_content_li_top_num fr"><a href="#" id="carCount"></a></div>
            </div>
            <div class="hr_5"></div>
            <div class="buy_content_li_list over_hidden clearfix" id="carlist">

            </div>
            <div  align="center" id="pageandsize"></div>
        </div>
    </div>


    <div class="hr_8"></div>
    <!--底部-->
    <jsp:include page="foot.jsp"></jsp:include>
    <!--底部-->
</div>
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script><!--必须得放在第一的位置-->
<!--<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>-->
<script type="text/javascript" src="js/buy.js"></script>
<script type="text/javascript" src="js/common.js"></script>
</body>
</html>
